namespace Sharpmark.PerfectLife.Core.HtmlDocument
{
    public class ImageGenerator : HtmlGenerator
    {
        public ImageGenerator() : base("img") { }

        public void GenerateImageHtml(
            string src, string alt,
            int border, int width, int height,
            ImageAlignType align)
        {
            NewAttribute("src", src);
            if (border != 0)
            {
                NewAttribute("border", border.ToString());
            }

            if (alt != null && alt != "")
            {
                NewAttribute("alt", alt);
            }

            if (width > 0)
            {
                NewAttribute("width", width.ToString());
            }

            if (height > 0)
            {
                NewAttribute("height", height.ToString());
            }

            if (align == ImageAlignType.LeftAlign)
            {
                NewAttribute("style", "margin: 0px 0px 10px 10px; float: left; cursor: pointer");
            }
            else if (align == ImageAlignType.RightAlign)
            {
                NewAttribute("style", "margin: 0px 0px 10px 10px; float: right; cursor: pointer");
            }

            CloseElement();
        }
    }

    public enum ImageAlignType
    {
        NotAlign,
        LeftAlign,
        RightAlign
    }
}
